{extend name="PublicBase/showBase" /}

{block name="body"}
<div class="main">
    <div class="row">
        <div class="col-md-12">
            <section class="tile color transparent-black">
                <div class="tile-header bg-transparent-black-2">
                    <h1>
                        {if condition="$Info eq ''"}
                            {:lang('XtPzXz')}
                        {else /}
                            {:lang('XtPzGx')}
                        {/if}
                    </h1>
                    <div class="controls">
                        <a href="javascript:void(0);" onclick="window.history.back();"><i class="fa fa-arrow-left"></i></a>
                        {if condition="$Info eq ''"}
                            <a href="{:url('SystemConfig/showAdd')}"><i class="fa fa-refresh"></i></a>
                        {else /}
                            <a href="{:url('SystemConfig/showEdit', array('id'=>$Info['config_id']))}"><i class="fa fa-refresh"></i></a>
                        {/if}
                    </div>
                </div>
                <div class="tile-body nopadding">
                    <form class="FormTable" action="" method="post">
                        <div class="tile-body">
                            <div class="row">
                                <div class="form-group col-sm-12">
                                    <label>{:lang('XtPzFz')}</label>
                                    <select class="chosen-select chosen-transparent form-control" name="config_group">
                                        {notempty name="Group"}
                                            {volist name="Group" id="vo"}
                                                <option value="{$vo.content_value}" {eq name="Info['config_group']" value="$vo['content_value']"}selected{/eq}>{$vo.content_name}</option>
                                            {/volist}
                                        {/notempty}
                                    </select>
                                </div>
                                <div class="form-group col-sm-12">
                                    <label>{:lang('XtPzBs')}</label>
                                    <input type="text" class="form-control" name="config_name" value="{$Info.config_name}" placeholder="{:lang('XtPzBsWk')}{:lang('XtPzBsAl')}" />
                                </div>
                                <div class="form-group col-sm-12">
                                    <label>{:lang('XtPzMc')}</label>
                                    <input type="text" class="form-control" name="config_title" value="{$Info.config_title}" placeholder="{:lang('XtPzMcWk')}" />
                                </div>
                                <div class="form-group col-sm-12">
                                    <label>{:lang('XtPzLx')}</label>
                                    <select class="chosen-select chosen-transparent form-control" name="config_type" id="config_type">
                                        <option value="1" {eq name="Info['config_type']" value="1"}selected{/eq}>{:lang('XtPzLx1')}</option>
                                        <option value="2" {eq name="Info['config_type']" value="2"}selected{/eq}>{:lang('XtPzLx2')}</option>
                                        <option value="3" {eq name="Info['config_type']" value="3"}selected{/eq}>{:lang('XtPzLx3')}</option>
                                    </select>
                                </div>
                                <div class="form-group col-sm-12" id="div_input">
                                    <label>{:lang('XtPzNr')}</label>
                                    <input type="text" class="form-control" name="config_value" value="{$Info.config_value}" id="config_input" placeholder="{:lang('XtPzNrWk')}" />
                                </div>
                                <div class="form-group col-sm-12" id="div_select" style="display:none">
                                    <label>{:lang('XtPzXl')}</label>
                                    <input type="text" class="form-control" name="config_select" value="{$Info.config_select}" id="config_select" placeholder="{:lang('XtPzXlWk')}{:lang('XtPzXlAl')}" />
                                </div>
                                <div class="form-group col-sm-12" id="div_images" style="display:none">
                                    <label for="file">{:lang('XtPzTp')}</label>
                                    <div class="input-group">
                                        <input type="text" class="form-control config_images" placeholder="{:lang('XtPzTpWk')}" readonly="readonly" style="background-color:rgba(0, 0, 0, 0.3);border: 0;color: rgba(255, 255, 255, 0.8);font-size: 12px;-webkit-font-smoothing: antialiased;line-height: 20px;" />
                                        <span class="input-group-btn">
                                            <span class="btn btn-{:config('CNF_BTNCOLOR')} btn-file">
                                                <i class="fa fa-upload"></i><input type="file" class="config_images" name="config_images" accept="image/jpeg,image/jpg,image/png" multiple="" />
                                            </span>
                                        </span>
                                    </div>
                                </div>
                                <div class="form-group col-sm-12">
                                    <label>{:lang('XtPzSm')}</label>
                                    <input type="text" class="form-control" name="config_remark" value="{$Info.config_remark}" placeholder="{:lang('XtPzSmWk')}" />
                                </div>
                                <div class="form-group col-sm-12">
                                    <label>{:lang('XtPzXs')}</label>
                                    <select class="chosen-select chosen-transparent form-control" name="config_show">
                                        <option value="2" {eq name="Info['config_show']" value="2"}selected{/eq}>{:lang('XtPzXs2')}</option>
                                        <option value="1" {eq name="Info['config_show']" value="1"}selected{/eq}>{:lang('XtPzXs1')}</option>
                                    </select>
                                </div>
                                <div class="form-group col-sm-12">
                                    <label>{:lang('XtPzPx')}</label>
                                    <input type="text" class="form-control" name="config_sort" value="{$Info.config_sort|default=0}" placeholder="{:lang('XtPzPxWk')}{:lang('XtPzPxAl')}" />
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="tile-footer bg-transparent-black-2 rounded-bottom-corners">
                    <div class="row">
                        <div class="col-sm-12 text-center">
                            <button type="button" class="btn btn-{:config('CNF_BTNCOLOR')} ajax-post">{:lang('XtAnTj')}</button>
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </div>
</div>
{/block}

{block name="script"}
    <script>
        $(document).on('change', '.btn-file :file',function(){
            var input = $(this),
            numFiles = input.get(0).files ? input.get(0).files.length : 1,
            label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
            input.trigger('fileselect', [numFiles, label]);
        });

        $(function(){
            {if condition="$Info['config_type'] eq 1"}
                $('#div_input').show();
                $('#div_select,#div_images').hide();
            {elseif condition="$Info['config_type'] eq 2" /}
                $('#div_input,#div_select').show();
                $('#div_images').hide();
            {elseif condition="$Info['config_type'] eq 3" /}
                $('#div_images').show();
                $('#div_input,#div_select').hide();
            {/if}

            $('#config_type').change(function(){
                $('#config_input,#config_select,.config_images').val('');
                var config_type = $('#config_type').val();
                if(config_type == 1){
                    $('#div_input').show();
                    $('#div_select,#div_images').hide();
                }else if(config_type == 2){
                    $('#div_input,#div_select').show();
                    $('#div_images').hide();
                }else if(config_type == 3){
                    $('#div_images').show();
                    $('#div_input,#div_select').hide();
                }
            });

            $('.btn-file :file').on('fileselect', function(event, numFiles, label){
                var input = $(this).parents('.input-group').find(':text'),
                log = numFiles > 1 ? numFiles + ' files selected' : label;
                console.log(log);
                if(input.length){
                    input.val(log);
                }else{
                    if(log)layer.msg(log);
                }
            });
        })
    </script>
{/block}
      
